﻿namespace Maple.Weixin.MP.Entities.Menus
{
    public sealed class MultiMenu : MenuBase
    {
        private readonly SingleMenu[] subMenus;

        public MultiMenu(string name, SingleMenu[] subMenus)
            : base(name) {
            this.subMenus = subMenus;
        }

        #region Overrides of MenuBase

        protected internal override object ToJsonObject() {
            var entity = new
                {
                    name = Name,
                    sub_button = new object[subMenus.Length]
                };
            for (int i = 0; i < subMenus.Length; i++) {
                entity.sub_button[i] = subMenus[i].ToJsonObject();
            }
            return entity;
        }

        #endregion

        public SingleMenu[] SubMenus {
            get { return subMenus; }
        }
    }
}
